<? if ($c = stack('name')) { 
	
	$d = component_data($c);
	$s = component_settings($c);

	?><div id="<?=$s['id']?>"></div>
	
	<style type="text/css" title="currentStyle" media="all">
		@import url(/lib/cal/<?=$s['css']?>.css);
	</style>
	
	<script type="text/javascript">
	
	function cal_<?=$c?>_data(date, d) {
    var info = <?=$s['id_data']?>[date.print("%Y-%m-%d")];
    if (!info) {
      return d + "<div class='info'>&nbsp;</div>";
    } else {
      return d + "<div class='info'>" + info.title + "</div>";
    }
  };

	
	Calendar.setup({
		flat         : "<?=$s['id']?>",
		flatCallback : function (cal) { 
			var temp;
			if (cal.dateClicked) {
				var y = cal.date.getFullYear();
				var m = cal.date.getMonth() + 1;
				var d = ((temp = cal.date.getDate()) > 9) ? temp : "0" + temp;      // integer, 1..31
				var info = <?=$s['id_data']?>["" + y + "-" + m + "-" + d];
				// redirect...
//				location.href = "<?=_transformURL($CURRENT->url, array('remove_param' => 'date'))?>" + y + "-" + (m + 1) + "-" + d + "/";

				if (info && info["image"] && info["image"]["fn"])
					xViewer.view(info["image"]["fn"], info["image"]["x"], info["image"]["y"]);

			 }
			return true;
		},
		dateText: cal_<?=$c?>_data,
		firstDay	:	1,
		weekNumbers: false,
		date: new Date(<?=$d['date']['y']?>, <?=$d['date']['m']-1?>, <?=$d['date']['d']?>)
	});
	</script>

	<?	unstack();
} ?>